package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.PaymentSheetUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import com.xbongbong.sys.domain.entity.UserEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/25 10:18
 * @since v1.0
 */
public interface PaymentSheetUserModel extends IModel<PaymentSheetUserEntity> {
    
    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return java.util.List<com.xbongbong.saas.domain.entity.PaymentSheetUserEntity>
     * @author chenshan
     * @date 2020/2/16 14:22
     */
    @Override
    List<PaymentSheetUserEntity> findEntitys(Map<String, Object> param);
    
    /**
     * 保存实体
     *
     * @param paymentUserEntity 回款协同人团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author chenshan
     * @date 2019/2/14 16:42
     */
    Integer save(PaymentSheetUserEntity paymentUserEntity) throws XbbException;
    
    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.PaymentUserEntity
     * @author chenshan
     * @date 2019/2/14 16:43
     */
    PaymentSheetUserEntity getByKey(Long key, String corpid);
    
    /**
     * 不去重获取所有的对应ContractUser(构造方法引起了findEntitys中当不需要获取所有字段的时候去重不符合要求)
     *
     * @param param 参数
     * @return 创建时间： 2018年1月4日 下午3:37:40
     * @author chenshan
     */
    List<PaymentSheetUserEntity> findAllEntitys(Map<String, Object> param);
    
    /**
     * Description: 获取合同负责人或协同人id list
     * @param corpid 公司id
     * @param paymentSheetId 回款单id
     * @param isMain 是否为负责人 1负责人 0 协同人
     * @return java.util.List<java.lang.String>
     * @author chenshan
     * @date 2019/2/20 17:15
     * @since v1.0
     */
    List<PaymentSheetUserEntity> getPaymentSheetUserIdList(String corpid, Long paymentSheetId, Integer isMain);
    /**
     * Description:批量获取合同负责人或协同人id
     * @param corpid 公司id
     * @param contractIds 合同ids
     * @param isMain 是否为负责人 1负责人 0 协同人
     * @return java.util.List<java.lang.String>
     * @author chenshan
     * @date 2019/2/20 17:13
     * @since v1.0
     */
    List<String> getContractUserIdList(String corpid, List<String> contractIds, Integer isMain);
    
    /**
     * 删除合同团队
     * @param contractUser
     */
    void delete(PaymentSheetUserEntity contractUser) throws XbbException;
    
    /**
     * 插入合同协同团队
     * @param userEntity
     * @param contractId
     * @param isMain
     * @throws XbbException 异常
     * @author chenshan
     * @date 2019-02-23 18:22
     */
    void contractUserInsert(UserEntity userEntity, Long contractId, Integer isMain) throws XbbException;
    
    /**
     * 查询协同团队基础列表
     * @param map 参数
     * @return 团队
     * @author chenshan
     */
    List<UserTeamEntity> findBaseEntitys(Map<String, Object> map);
    
    /**
     * 批量删除
     * @author chenshan
     * @date 2019/3/13 16:20
     * @param contractIdIn 合同id
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer deleteByContractIdIn(List<Long> contractIdIn, String corpid) throws XbbException;
    /**
     * 获取协同团队的业务数据
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     * @author chenshan
     * @date 2019-03-20 15:34
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);
    
    
    void insertBatch(List<PaymentSheetUserEntity> paymentUserEntityList) throws XbbException;

    void insertBatch(List<PaymentSheetUserEntity> paymentUserEntityList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void insertBatch(List<PaymentSheetUserEntity> paymentUserEntityList, boolean needThrow) throws XbbException;
    
    /**
     * 批量剔除团队
     * @param corpid
     * @param removeList 汇款团队
     */
    void batchDelete(String corpid, List<PaymentSheetUserEntity> removeList,boolean needThrow) throws XbbException;
    
    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del,boolean needThrow) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void deleteByPaymentSheetIds(List<Long> dataIds, String corpid) throws XbbException;

    /**
     * 编辑协同人表单权限
     *
     * @param shouldUpdateEntity
     */
    void updateEditFormPer(PaymentSheetUserEntity shouldUpdateEntity) throws XbbException;

    /**
     * 编辑标签
     *
     * @param paymentSheetUserEntity
     */
    void editLabel(PaymentSheetUserEntity paymentSheetUserEntity) throws XbbException;

    /**
     * 批量解散团队依据客户id
     *
     * @param corpid
     * @param customerIdList
     */
    void disbandedTeamByCustomerId(String corpid, List<Long> customerIdList) throws XbbException;

    /**
     * 批量更新回款单团队的删除标识，这边一开始是为了工作流撤回使用 删除标识是6；后面如果其它要使用注意一下
     *
     * @param corpid
     * @param paymentSheetUserEntities
     * @param del
     */
    void deleteBatchUser(String corpid, List<PaymentSheetUserEntity> paymentSheetUserEntities, Integer del) throws XbbException;
}
